package com.itheima.d4_proxy;

public class Demo1 {
    public static void main(String[] args) {
        BaoQiang baoQiang = new BaoQiang();
        SongJiJi songJiJi = new SongJiJi(baoQiang);
        songJiJi.liveShow(100000);
        songJiJi.sleep();
    }
}

class SongJiJi implements Star{
    BaoQiang baoQiang;
    public SongJiJi(BaoQiang baoQiang){
        this.baoQiang = baoQiang;
    }

    @Override
    public double liveShow(double money) {
        System.out.println("宋吉吉 拉了一场真人秀，赚了"+money);
        double baoqiangMoney = baoQiang.liveShow(money * 0.7);
        System.out.println("宋吉吉把钱存起来"+baoqiangMoney);
        return baoqiangMoney;
    }

    @Override
    public void sleep() {
        System.out.println("宋吉吉 订了一家五星级酒店");
        baoQiang.sleep();
        System.out.println("宋吉吉退房");
    }
}
//被代理对象
class BaoQiang implements Star{
    @Override
    public double liveShow(double money) {
        System.out.println("宝强参加真人秀,睡了"+money);
        return money;
    }

    @Override
    public void sleep() {
        System.out.println("宝强累了，需要睡觉");
    }
}

interface Star{
    double liveShow(double money);
    void sleep();
}



































